﻿(function(){function g(b,d){var a=b.getCursor(),c=b.getTokenAt(a),f=CodeMirror.innerMode(b.getMode(),c.state),h=f.state;if("xml"!=f.mode.name)throw CodeMirror.Pass;var e=b.getOption("autoCloseTags"),i="html"==f.mode.configuration,f="object"==typeof e&&e.dontCloseTags||i&&k,i="object"==typeof e&&e.indentTags||i&&l;if(">"==d&&h.tagName){e=h.tagName;c.end>a.ch&&(e=e.slice(0,e.length-c.end+a.ch));var g=e.toLowerCase();if("tag"==c.type&&"closeTag"==h.type||/\/\s*$/.test(c.string)||f&&-1<j(f,g))throw CodeMirror.Pass;
c=i&&-1<j(i,g);b.replaceSelection(">"+(c?"\n\n":"")+"</"+e+">",c?{line:a.line+1,ch:0}:{line:a.line,ch:a.ch+1});c&&(b.indentLine(a.line+1),b.indentLine(a.line+2))}else if("/"==d&&"tag"==c.type&&"<"==c.string)(e=h.context&&h.context.tagName)&&b.replaceSelection("/"+e+">","end");else throw CodeMirror.Pass;}function j(b,d){if(b.indexOf)return b.indexOf(d);for(var a=0,c=b.length;a<c;++a)if(b[a]==d)return a;return-1}CodeMirror.defineOption("autoCloseTags",!1,function(b,d,a){if(d&&(a==CodeMirror.Init||!a)){a=
{name:"autoCloseTags"};if(typeof d!="object"||d.whenClosing)a["'/'"]=function(a){g(a,"/")};if(typeof d!="object"||d.whenOpening)a["'>'"]=function(a){g(a,">")};b.addKeyMap(a)}else!d&&(a!=CodeMirror.Init&&a)&&b.removeKeyMap("autoCloseTags")});var k="area base br col command embed hr img input keygen link meta param source track wbr".split(" "),l="applet blockquote body button div dl fieldset form frameset h1 h2 h3 h4 h5 h6 head html iframe layer legend object ol p select table ul".split(" ")})();